SET DATEFORMAT MDY;

SET NOCOUNT ON;

-- populate the table
DECLARE @Date DATETIME = '01/01/2013';
DECLARE @Loop INT = 1;

-- insert 1500 sales per day
WHILE @Loop < 547600
BEGIN
	INSERT INTO dbo.BigTable (
		SalesDate, SalesDescription, CustomerID, ProductID, Quantity, Price, PayDate, Discount, WarehouseID, PickerID, ShipperID)
    VALUES (
		@Date,
        LEFT(REPLACE(CAST(NEWID() AS NVARCHAR(MAX)),'-',''), ABS(CHECKSUM(NEWID())) % 100 + 1),
		CONVERT (INT, (RAND () * 1000)),
        CONVERT (INT, (RAND () * 1000)),
        CONVERT (INT, (RAND () * 10)),
        ROUND (RAND () * 1000, 2),
		DATEADD(day, CONVERT (INT, (RAND() * (30 - 3 - 1) + 3)) , @Date),    -- paydate between @Date + 3 days and @Date + 30 days
		CONVERT (INT, (RAND () * 14)),  -- discount between 0 and 15
		1,
        CONVERT (INT, (RAND () * 4)),
        CONVERT (INT, (RAND () * 4))
		);
   
	IF @Loop % 1500 = 0
		SET @Date += 1;
   
    SET @Loop += 1;
END
GO

-- and a clustered index
CREATE UNIQUE CLUSTERED INDEX CIX_BigTable
ON dbo.BigTable (SalesID);
GO
